<?php
pc_base::load_app_class('hchbase','hchindex',0);
class ajax extends hchbase {
	
	function __construct() {
		parent::__construct();
		$this->dbCrowdfunding = pc_base::load_model("mycrowdfunding_model");
	}
	
	public function regService(){
		include template ( 'content/member', 'service.html' );
	}
	

	public function regApp(){
		include template ( 'content/member', 'app.html' );
	}
	
	
	public function browsecrowdfunding(){
		$id = $_GET['id'];
		$browse = $_GET['br'];
		$item['browse_times'] = $browse + 1;
		$this->dbCrowdfunding->update($item,$where = 'id = "'.$id.'"');
	
	
		echo $item['browse_times'];
	}
	
	public function fav(){
		$item['crowdfunding_id'] = $_GET['id'];
		$item['crowdfunding_name'] = $_GET['name'];
		$item['user_id'] = param::get_cookie("_userid");
		$item['user_name'] = param::get_cookie("_username");
		$item['relation_type'] = 2;
		$item['company'] = '';
		$dbU2C = pc_base::load_model('myuser2crowdfunding_model');
		$u2cId = $dbU2C->insert($item,true);
		if($u2cId>0){
			echo '1';
		}else{
			echo '0';
		}
	}
	
	public function takecomment(){
		$item['content'] = $_GET['comment'];
		$item['comment_type'] = $_GET['type'];
		$item['project_id'] = $_GET['id'];
		$item['user_id'] = param::get_cookie("_userid");
		$item['username'] = param::get_cookie("_username");
        $item['last_updated_time'] = $this->CURRENT_DATETIME;
        $item['created_time'] = $this->CURRENT_DATETIME;
		
		if(!$item['user_id']){
			die('nologin');
		}
		if(!$item['content']){
			die('nocontent');
		}
		$dbComment = pc_base::load_model("mycomment_model");
		$id = $dbComment->insert($item,true);
	}
	
	public function zan(){
		$id = $_GET['id'];		
		$dbComment = pc_base::load_model("mycomment_model");
		$whereSql = array('id'=>$id);
		$item = $dbComment->get_one($whereSql,'*');
		
		if($item){
			$zanNumber = $item['zan_number'] + 1;
			$data['zan_number'] = $zanNumber;
			$dbComment->update($data,$where = 'id = "'.$id.'"');
			return 1;
		}else{
			return 0;
		}
		
	}
}
?>